package cuongnh.project.japanesediary.vocabulary.ui.wizard;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import cuongnh.project.japanesediary.vocabulary.common.CommonServices;
import cuongnh.project.japanesediary.vocabulary.model.Sentence;
import cuongnh.project.japanesediary.vocabulary.ui.wizard.page.NewSentenceWizardPage;

@Component("newSentenceWizard")
@Scope("prototype")
public class AddSentenceWizard extends Wizard implements INewWizard{

	private Sentence example;
	private NewSentenceWizardPage page;
	private IWorkbench workbench;

	@Autowired
	private CommonServices commonServices;
	
	public AddSentenceWizard() {
		setWindowTitle("New Wizard");
		this.example = new Sentence();
	}

	public AddSentenceWizard(CommonServices commonServices,
			Sentence example) {
		setWindowTitle("New Wizard");
		this.example = example;
		this.commonServices = commonServices;
	}

	@Override
	public void addPages() {
		page = new NewSentenceWizardPage(example);
		addPage(page);
	}

	@Override
	public boolean performFinish() {
		commonServices.getSentenceDao().saveOrUpdate(example);
		return true;
	}

	@Override
	public void init(IWorkbench workbench, IStructuredSelection selection) {
		this.workbench = workbench;
		
	}
	
	

}
